import { Schema } from "mongoose";

const roomMessageSchema = new Schema({
  roomId: {
    type: Schema.Types.ObjectId,
    ref: "ChatRoom",
    required: true,
  },
  senderId: {
    type: Schema.Types.ObjectId,
    ref: "User",
    required: true,
  },
  content: {
    type: String,
    required: true,
  },
  timestamp: {
    type: Date,
    default: Date.now,
  },
  // 消息类型
  messageType: {
    type: String,
    enum: ["text", "image", "audio", "video"],
    default: "text",
  },
  // 系统消息，用户消息
  type: {
    type: String,
    enum: ["system", "user"],
    default: "user",
  },
  read: {
    type: Boolean,
    default: false,
  },
});

export default roomMessageSchema;
